var jizhang={

    zhicu:function () {
        $.ajax({
            type:"post",
            url:basePath + "/jizhang/zhicu",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify({
                payIncome:{
                    ctid:$("#ctid").val(),
                    money:$("#txtPwd").val(),
                    date:$("#date").val(),
                    detail:$("#detail").val()
                },
                acc_id:$("#acc_id").val()
            }),
            success:function (msg) {

                if (msg=="success"){
                    window.location.href= ip_port + "jizhang/index";
                }else if("moneyShort"==msg){
                    alert("账户余额不足");
                }else{
                    alert(msg);
                }

            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });
    },

    shouru:function () {
        $.ajax({
            type:"post",
            url:basePath + "/jizhang/shouru",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify({
                payIncome:{
                    ctid:$("#ctid_shouru").val(),
                    money:$("#shouru").val(),
                    date:$("#date_shouru").val(),
                    detail:$("#detail_shouru").val()
                },
                acc_id:$("#acc_id_shouru").val()
            }),
            success:function (msg) {
                if (msg=="success"){

                    window.location.href= ip_port + "jizhang/index";
                }else{

                    alert(msg);
                }

            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });
    },

    zhuangzhuang:function () {


        $.ajax({
            type:"post",
            url:basePath + "/jizhang/zhuangzhang",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify(
               {
                    accountInId:$("#accountInId_zhuangchu").val(),
                    accountOutId:$("#accountOutId_zhuangchu").val(),
                    transferDate:$("#date_zhuangzhang").val(),
                    transferMoney:$("#transfer").val(),
                    detail:$("#detail_zhuangzhang").val()
                }
            ),
            success:function (msg) {
                if (msg=="success"){

                    window.location.href= ip_port + "jizhang/index";
                }else if(msg == "accError"){
                    alert("相同的账户之间不能转账");
                }else if(msg == "yuError"){
                    alert("账户余额不足");
                }else if(msg == "error"){

                    alert("发送内部错误");
                }
            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });
    },

    jianru:function () {


        $.ajax({
            type:"post",
            url:basePath + "/jizhang/jianru",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify(
                {
                    accountInId:$("#accountInId_jianru").val(),
                    accountOutId:$("#accountOutId_jianru").val(),
                    transferDate:$("#date_jianru").val(),
                    transferMoney:$("#jieru").val(),
                    detail:$("#detail_jieru").val()
                }
            ),
            success:function (msg) {
                if (msg=="success"){

                    window.location.href= ip_port + "jizhang/index";
                }else{
                    alert(msg);
                }
            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });
    },


    jiancu:function () {

        $.ajax({
            type:"post",
            url:basePath + "/jizhang/jiancu",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify(
                {
                    accountInId:$("#accountInId_jiancu").val(),
                    accountOutId:$("#accountOutId_jiancu").val(),
                    transferDate:$("#date_jiancu").val(),
                    transferMoney:$("#jiecu").val(),
                    detail:$("#detail_jiecu").val()
                }
            ),
            success:function (msg) {
                if (msg=="success"){

                    window.location.href= ip_port + "jizhang/index";
                }else if("moneyShort"==msg){
                    alert("账户余额不足");
                }else{
                    alert(msg);
                }
            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });
    },

    huankuan:function () {

        $.ajax({
            type:"post",
            url:basePath + "/jizhang/huankuan",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify(
                {
                    accountInId:$("#accountInId_huankuan").val(),
                    accountOutId:$("#accountOutId_huankuan").val(),
                    transferDate:$("#date_huankuan").val(),
                    transferMoney:$("#huankuan").val(),
                    detail:$("#detail_huankuan").val()
                }
            ),
            success:function (msg) {
                if (msg=="success"){

                    window.location.href= ip_port + "jizhang/index";
                }else if("moneyError"==msg){
                    alert("账户余额不足");
                }else{
                    alert(msg);
                }
            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });
    },

    shouzai:function () {

        $.ajax({
            type:"post",
            url:basePath + "/jizhang/shouzai",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify(
                {
                    accountInId:$("#accountInId_shouzai").val(),
                    accountOutId:$("#accountOutId_shouzai").val(),
                    transferDate:$("#date_shouzai").val(),
                    transferMoney:$("#souzai").val(),
                    detail:$("#detail_shouzai").val()
                }
            ),
            success:function (msg) {
                if (msg=="success"){

                    window.location.href= ip_port + "jizhang/index";
                }else if("moneyError"==msg){
                    alert("收债金额不对");
                }else{
                    alert(msg);
                }
            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });
    },


    list_do_list:function () {

        $.ajax({
            type:"post",
            url:basePath + "/jizhang/do_list_do",
            contentType:'application/json',
            dataType:"json",
            data:JSON.stringify({
                start:$("#start").val(),
                end:$("#end").val()
            }),
            success:function (msg) {

                var head="<tr >"+
                "<th style=\"text-align:center;\"><span style=\"\">编号</span></th>"+
                "<th style=\"text-align:center;\"><span class=\"STYLE10\">分类</span></th>"+
                "<th style=\"text-align:center;\"><span class=\"STYLE10\">金额</span></th>"+
                "<th style=\"text-align:center;\"><span class=\"STYLE10\">账户</span></th>"+
                "<th style=\"text-align:center;\"><span class=\"STYLE10\">对方账户</span></th>"+
                "<th style=\"text-align:center;\"><span class=\"STYLE10\">标识</span></th>"+
                "<th style=\"text-align:center;\"><span class=\"STYLE10\">备注</span></th>"+
                "</tr>";



                var start=" <tr>";
                var end = "</tr>";
                var str="";

                $.each(msg,function () {
                    str+=start;
                    str+="<td style=\"text-align:center;\">" + this.id+  "</td>";
                    str+="<td style=\"text-align:center;\">" + this.doName+ "</span></td>";
                    str+="<td style=\"text-align:center;\">" + this.recordMoney+  "</span></td>";
                    str+="<td style=\"text-align:center;\">" + this.accId+  "</span></td>";
                    if (this.accOutId==null||this.accOutId==""){
                      str+="<td style=\"text-align:center;\">" + ""+  "</span></td>";
                    }else{
                      str+="<td style=\"text-align:center;\">" + this.accOutId +  "</span></td>";
                    }

                    if (this.flag==1){
                      str+="<td style=\"text-align:center;\"><span   style='color:red'>" + "支"+  "</span></td>";
                    }else if(this.flag==2){
                        str+="<td style=\"text-align:center;\"><span   style='color:green'>" + "收" +  "</span></td>";
                    }else{

                        str+="<td style=\"text-align:center;\"><span >" + "" +  "</span></td>";
                    }


                    str+="<td style=\"text-align:center;\"><span >" + this.detail+  "</span></td>";
                    str+=end;
                });

                $("#tb_do_list").html(head + str);
            },
            error:function (error) {
                alert("请求发生错误！");
            }
        });

    }








}